<template>
  <div>
    <div class="top-box">
      <div class="top-box-left">积分兑换</div>
    </div>
    <div class="boxs">
      <div class="type">
        <!-- <div class="content">商品类型</div> -->
            <div class="box" v-for = "item of goods" :key = "item.commodityId" @click="exchangeClick(item)">
              <div class="box-img">
                <img class="box-img-content" :src="item.image" alt="">
              </div>
              <div class="box-content">
                <div class="box-content-text">{{item.name}}</div>
                <div class="iconfont box-content-text">&#xe87f;{{item.price}}积分</div>
              </div>
            </div>
      </div>
    </div>
  </div>
</template>

<script>
import axios from 'axios'
export default {
  name: 'MallGoods',
  data () {
    return {
      value: '',
      goods: []
    }
  },
  created () {
    axios({
      method: 'get',
      url: '/brand'
    }).then((res) => {
      this.goods = res.data.data
      console.log(this.goods, 'haha')
    })
  },
  methods: {
    handleCommand (command) {
      this.$message('click on item ' + command)
    },
    exchangeClick (item) {
      console.log(item)
      this.$router.push({name: 'MallExchange', params: item})
    }
  },
  mounted () {

  }
}
</script>

<style lang="scss" scoped>
@import '../../assets/styles/global';
  .top-box{
    height: 30px;
    line-height: 30px;
    width: 100%;
    padding-left: 6px;
    background: skyblue;
    .top-box-left{
      float: left;
    }
    .top-box-right{
      float: right;
      padding-right: 8px;
      height: 35px;
      .select{
        width: 130px;
    }
    }
  }
  .boxs{
    width: 100%;
    margin-bottom: 80px;
    .type{
      overflow: hidden;
      .content{
        height: 20px;
        line-height: 20px;
        margin-left: 5px;
      }
      .box{
        float: left;
        overflow: hidden;
        position: relative;
        width: 30%;
        padding-bottom: 43%;
        margin: 1.3%;
        box-shadow: 2px 2px 2px 2px rgba(0, 0, 0, .06);
        border-radius: 10px;
        background: white;
        .box-img{
          position: absolute;
          top: 0;
          left: 0;
          right: 0;
          bottom: 45px;
          box-sizing: border-box;
          padding: 3px;
          .box-img-content{
            display: block;
            margin: 0 auto;
            // 使图片居中
            width: 100%;
          }
        }
        .box-content{
          position: absolute;
          left: 0;
          right: 0;
          bottom: 0;
          height: 45px;
          font-size: 14px;
          color: black;
          .box-content-text{
            margin: 4px;
            height: 20px;
            @include ellipsis;
          }
        }
      }
    }
  }

</style>
